<template>
	<view>
		<u-navbar title="操作日志" @rightClick="rightClick" :placeholder="true" :autoBack="true"></u-navbar>
		<!-- <z-paging ref="paging" use-page-scroll @onRefresh="onRefresh" v-model="list" @query="getList"> -->
		<!-- 页面内容 -->
		<scroll-view style="height: 82vh;" scroll-y @scrolltolower="handleScrolltolower" v-if="list.length != 0">
			<view class="container">
				<view class="list" v-for="(item,index) in list" :key="index">
					<view class="item-1">
						<view class="item-1-left"> {{item.operator}} </view>
						<view class="item-1-right"> {{item.operationAt}} </view>
					</view>
					<view class="item-2">
						<text class="label">操作类型：</text>
						<text class="item-2-type">{{item.operationType}}</text>
					</view>
					<view class="item-3">
						<text class="label">变更前后状态：</text>
						<text class="item-3-status">{{item.beforeStatus || "--"}}</text>
						<text class="item-3-rightIcon">
							<image src="/static/rightIcon.png" style="width: 32rpx;height: 18rpx;" mode=""></image>
						</text>
						<text class="item-3-status">{{item.afterStatus || "--"}}</text>
					</view>
					<view class="item-4">
						<view class="item-4-item">
							{{item.content || '--'}}
						</view>
					</view>
				</view>
			</view>
			<u-loadmore :status="loadmoreStatus" />
		</scroll-view>

		<!-- </z-paging> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
				total: 0,
				page: {
					pageNum: 1,
					pageSize: 10,
				},
				loadmoreStatus: "loadmore",
			}
		},
		onLoad(options) {
			if (options) {
				this.getList(options.id);
			}
		},
		created() {

		},
		methods: {
			//触底加载
			handleScrolltolower() {
				console.log("进入");
				if (this.total > this.list.length) {
					this.page.pageNum++;
					this.loadmoreStatus = "loading";
					this.getList();
				} else {
					this.loadmoreStatus = "nomore";
				}
			},
			getList(id) {
				uni.showLoading({
					title: '加载中'
				});
				this.api.exchangeOperLogList({
					...this.page,
					entityId: id
				}).then(res => {
					uni.hideLoading();
					console.log(res);
					this.total = res.data.total;
					if (this.total > this.list.length) {
						this.list = this.list.concat(res.data.rows);
					} else {
						this.loadmoreStatus = "nomore";
					}
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	page {
		background-color: #F6F6F6;
	}

	.container {
		margin: 20rpx;

		.list {
			background: #FFFFFF;
			border-radius: 16rpx 16rpx 16rpx 16rpx;
			margin: 10rpx;
			padding: 20rpx;

			.label {
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				font-size: 28rpx;
				color: #999999;
				line-height: 32rpx;
				text-align: left;
				font-style: normal;
				text-transform: none;
			}

			.item-1 {
				display: flex;
				align-items: center;
				justify-content: space-between;

				.item-1-left {
					font-family: PingFang SC, PingFang SC;
					font-weight: 500;
					font-size: 32rpx;
					color: #000000;
					line-height: 32rpx;
					text-align: left;
					font-style: normal;
					text-transform: none;
				}

				.item-1-right {
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					font-size: 28rpx;
					color: #333333;
					line-height: 32rpx;
					text-align: left;
					font-style: normal;
					text-transform: none;
				}
			}

			.item-2 {
				margin-top: 20rpx;

				.item-2-type {
					font-family: PingFang SC, PingFang SC;
					font-weight: 500;
					font-size: 28rpx;
					color: #15298C;
					line-height: 32rpx;
					text-align: left;
					font-style: normal;
					text-transform: none;
				}
			}

			.item-3 {
				margin-top: 20rpx;

				.item-3-rightIcon {
					margin: 0rpx 10rpx;
				}

				.item-3-status {
					font-family: PingFang SC, PingFang SC;
					font-weight: 500;
					font-size: 28rpx;
					color: #FF1212;
					line-height: 32rpx;
					text-align: left;
					font-style: normal;
					text-transform: none;
				}
			}

			.item-4 {
				margin-top: 20rpx;
				padding: 10rpx;
				background: #F3F5FF;
				border-radius: 16rpx 16rpx 16rpx 16rpx;

				.item-4-item {
					margin: 10rpx 0rpx;
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					font-size: 28rpx;
					color: #333333;
					line-height: 36rpx;
					text-align: left;
					font-style: normal;
					text-transform: none;
				}
			}
		}
	}
</style>